﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
                    xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
                    xmlns:System="clr-namespace:System;assembly=mscorlib" xmlns:Fluent="clr-namespace:Fluent">
  <Fluent:IconConverter x:Key="IconConvert" />
  <BitmapImage x:Key="ImageCaptionButtonClose"
               UriSource="pack://application:,,,/Fluent;component/Themes/Office2010/Images/CaptionButtonClose.png"
               PresentationOptions:Freeze="True" />
  <BitmapImage x:Key="ImageCaptionButtonMinimize"
               UriSource="pack://application:,,,/Fluent;component/Themes/Office2010/Images/CaptionButtonMinimize.png"
               PresentationOptions:Freeze="True" />
  <BitmapImage x:Key="ImageCaptionButtonNormalize"
               UriSource="pack://application:,,,/Fluent;component/Themes/Office2010/Images/CaptionButtonNormalize.png"
               PresentationOptions:Freeze="True" />
  <BitmapImage x:Key="ImageCaptionButtonMaximize"
               UriSource="pack://application:,,,/Fluent;component/Themes/Office2010/Images/CaptionButtonMaximize.png"
               PresentationOptions:Freeze="True" />
  <Style TargetType="{x:Type ResizeGrip}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ResizeGrip}">
          <Grid Width="11" Height="11" Background="Transparent">
            <Grid Width="3" Height="3" HorizontalAlignment="Right" VerticalAlignment="Bottom">
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripBack}" HorizontalAlignment="Right"
                         VerticalAlignment="Bottom" />
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripFront}" HorizontalAlignment="Left"
                         VerticalAlignment="Top" />
            </Grid>
            <Grid Width="3" Height="3" HorizontalAlignment="Center" VerticalAlignment="Bottom">
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripBack}" HorizontalAlignment="Right"
                         VerticalAlignment="Bottom" />
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripFront}" HorizontalAlignment="Left"
                         VerticalAlignment="Top" />
            </Grid>
            <Grid Width="3" Height="3" HorizontalAlignment="Left" VerticalAlignment="Bottom">
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripBack}" HorizontalAlignment="Right"
                         VerticalAlignment="Bottom" />
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripFront}" HorizontalAlignment="Left"
                         VerticalAlignment="Top" />
            </Grid>
            <Grid Width="3" Height="3" HorizontalAlignment="Right" VerticalAlignment="Center">
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripBack}" HorizontalAlignment="Right"
                         VerticalAlignment="Bottom" />
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripFront}" HorizontalAlignment="Left"
                         VerticalAlignment="Top" />
            </Grid>
            <Grid Width="3" Height="3" HorizontalAlignment="Center" VerticalAlignment="Center">
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripBack}" HorizontalAlignment="Right"
                         VerticalAlignment="Bottom" />
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripFront}" HorizontalAlignment="Left"
                         VerticalAlignment="Top" />
            </Grid>
            <Grid Width="3" Height="3" HorizontalAlignment="Right" VerticalAlignment="Top">
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripBack}" HorizontalAlignment="Right"
                         VerticalAlignment="Bottom" />
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripFront}" HorizontalAlignment="Left"
                         VerticalAlignment="Top" />
            </Grid>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <ControlTemplate x:Key="DwmRibbonWindowControlTemplate" TargetType="{x:Type Fluent:RibbonWindow}">
    <Grid>
      <AdornerDecorator x:Name="adornerDecorator" Margin="0">
        <Grid x:Name="PART_MainGrid" Margin="0" Background="{DynamicResource TransparentBrush}"
              VerticalAlignment="Stretch">
          <Grid x:Name="PART_TitleBar" Margin="8" VerticalAlignment="Top" Height="{TemplateBinding CaptionHeight}"
                Background="{DynamicResource TransparentBrush}" IsHitTestVisible="True" />
          <Rectangle x:Name="rectangle" Stroke="{x:Null}" HorizontalAlignment="Left" Width="35" StrokeThickness="0"
                     Margin="15,27,0,1" VerticalAlignment="Top" Height="23" IsHitTestVisible="False"
                     Fill="{DynamicResource RibbonTabControlTopGradientLeftBrush}" SnapsToDevicePixels="True" />
          <Rectangle x:Name="rectangle1" Stroke="{x:Null}" HorizontalAlignment="Right" Width="35" StrokeThickness="0"
                     Margin="0,27,15.1,1" Height="23" VerticalAlignment="Top" IsHitTestVisible="False"
                     Fill="{DynamicResource RibbonTabControlTopGradientRightBrush}" SnapsToDevicePixels="True" />
          <Rectangle x:Name="rectangle2" Stroke="{x:Null}" HorizontalAlignment="Stretch" Width="Auto"
                     StrokeThickness="0" Height="23" Margin="50,27,50,1" VerticalAlignment="Top" IsHitTestVisible="False"
                     Fill="{DynamicResource RibbonTabControlTopGradientCenterBrush}" SnapsToDevicePixels="True" />

          <Grid x:Name="grid" Background="{TemplateBinding Background}" Margin="{TemplateBinding GlassBorderThickness}" />
          <StackPanel Background="Transparent" x:Name="PART_IconImage" Margin="8,7,8,8" Orientation="Horizontal"
                      HorizontalAlignment="Left" VerticalAlignment="Top">
            <Image x:Name="iconImage" Height="16" HorizontalAlignment="Left" VerticalAlignment="Top"
                   Source="{Binding Icon, Converter={StaticResource IconConvert}, RelativeSource={RelativeSource TemplatedParent}}"
                   Width="16" SnapsToDevicePixels="True" />
          </StackPanel>
          <ContentPresenter Margin="8,1,8,8" x:Name="contentPresenter" />
          <ResizeGrip x:Name="PART_ResizeGrip" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right"
                      VerticalAlignment="Bottom" Focusable="False" Margin="0,0,5.5,5.5" Background="Transparent" Visibility="Collapsed" />
        </Grid>
      </AdornerDecorator>
    </Grid>
    <ControlTemplate.Triggers>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="ResizeMode" Value="CanResizeWithGrip" />
          <Condition Property="WindowState" Value="Normal" />
        </MultiTrigger.Conditions>
        <Setter Property="Visibility" TargetName="PART_ResizeGrip" Value="Visible" />
      </MultiTrigger>
      <Trigger Property="WindowState" Value="Maximized">
        <Setter Property="Margin" TargetName="iconImage" Value="0,4,0,0" />
        <Setter Property="Margin" TargetName="adornerDecorator" Value="0" />
        <Setter Property="Margin" TargetName="contentPresenter" Value="8,6,8,8" />
        <Setter Property="Margin" TargetName="rectangle" Value="15,31,0,1" />
        <Setter Property="Margin" TargetName="rectangle1" Value="0,31,15.1,1" />
        <Setter Property="Margin" TargetName="rectangle2" Value="50,31,50,1" />
      </Trigger>
      <Trigger Property="IsIconVisible" Value="False">
        <Setter Property="Visibility" TargetName="PART_IconImage" Value="Collapsed" />
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <ControlTemplate x:Key="NonDwmRibbonWindowControlTemplate" TargetType="{x:Type Fluent:RibbonWindow}">
    <Grid>
      <AdornerDecorator x:Name="adornerDecorator" VerticalAlignment="Stretch" Margin="0">
        <Grid>
          <Border x:Name="PART_SizeBorder" BorderBrush="{DynamicResource WindowOutterBorderBrush}"
                  BorderThickness="1,1,1,1" CornerRadius="8.5" Opacity="1" Background="{DynamicResource WindowOutterBackgroundBrush}">
            <Border x:Name="border2" BorderBrush="{DynamicResource WindowInnerBorderBrush}" BorderThickness="1,1,1,1"
                    CornerRadius="7,7,7,7" Background="{x:Null}" Opacity="1">
              <Border x:Name="border3" BorderBrush="{x:Null}" BorderThickness="0,0,0,0" Opacity="1" CornerRadius="6"
                      VerticalAlignment="Top" Height="50" Background="{DynamicResource WindowInnerBackgroundBrush}" />
            </Border>
          </Border>
          <Grid x:Name="PART_MainGrid" Margin="0" Background="#00FFFFFF">
            <Grid x:Name="PART_TitleBar" Margin="{TemplateBinding ResizeBorderThickness}" VerticalAlignment="Top"
                  Height="{TemplateBinding CaptionHeight}" Background="#00FFFFFF" IsHitTestVisible="True" />
            <StackPanel Background="Transparent" x:Name="PART_IconImage" Margin="8,7,0,0" Orientation="Horizontal"
                        HorizontalAlignment="Left" VerticalAlignment="Top">
              <Image x:Name="iconImage" Height="16" HorizontalAlignment="Left" VerticalAlignment="Top"
                     Source="{Binding Icon, Converter={StaticResource IconConvert}, RelativeSource={RelativeSource TemplatedParent}}"
                     Width="16" SnapsToDevicePixels="True" Stretch="Uniform" />
            </StackPanel>
            <StackPanel x:Name="PART_ButtonsPanel" HorizontalAlignment="Right" Margin="0,8,8,0" VerticalAlignment="Top"
                        Orientation="Horizontal">
              <Button x:Name="minimizeButton" Style="{DynamicResource CaptionButtonStyle}" Width="35" Height="19"
                      BorderThickness="1,0,0,1" Command="{x:Static Fluent:RibbonWindow.MinimizeCommand}">
                <Image Width="Auto" Height="Auto" HorizontalAlignment="Center" VerticalAlignment="Center"
                       Stretch="None" Source="{DynamicResource ImageCaptionButtonMinimize}" SnapsToDevicePixels="True" />
              </Button>
              <Button x:Name="maximizeButton" Margin="-1,0,0,0" Style="{DynamicResource CaptionButtonStyle}" Width="35"
                      Height="19" BorderThickness="0,0,0,1" Command="{x:Static Fluent:RibbonWindow.MaximizeCommand}">
                <Image Width="Auto" Height="Auto" HorizontalAlignment="Center" VerticalAlignment="Center"
                       Stretch="None" Source="{DynamicResource ImageCaptionButtonMaximize}" SnapsToDevicePixels="True" />
              </Button>
              <Button x:Name="normalizeButton" Margin="-1,0,0,0" Style="{DynamicResource CaptionButtonStyle}"
                      Width="35" Height="19" BorderThickness="0,0,0,1" Command="{x:Static Fluent:RibbonWindow.NormalizeCommand}">
                <Image Width="Auto" Height="Auto" HorizontalAlignment="Center" VerticalAlignment="Center"
                       Stretch="None" Source="{DynamicResource ImageCaptionButtonNormalize}" SnapsToDevicePixels="True" />
              </Button>
              <Button x:Name="closeButton" Margin="-1,0,0,0" Style="{DynamicResource CaptionButtonStyle}" Width="35"
                      Height="19" BorderThickness="0,0,1,1" Background="Red" Command="{x:Static Fluent:RibbonWindow.CloseCommand}">
                <Image Width="Auto" Height="Auto" HorizontalAlignment="Center" VerticalAlignment="Center"
                       Stretch="None" Source="{DynamicResource ImageCaptionButtonClose}" SnapsToDevicePixels="True" />
              </Button>
            </StackPanel>
            <Border x:Name="border4" Margin="{TemplateBinding GlassBorderThickness}">
              <Border x:Name="border1" Height="Auto" BorderThickness="1,1,1,1"
                      BorderBrush="{DynamicResource WindowContentBorderBrush}" Margin="-1">
                <Grid x:Name="grid" Background="{TemplateBinding Background}" />
              </Border>
            </Border>
            <ContentPresenter Margin="8,1,8,8" x:Name="contentPresenter" />
            <ResizeGrip x:Name="PART_ResizeGrip" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right"
                        VerticalAlignment="Bottom" Focusable="False" Margin="0,0,5.5,5.5" Cursor="SizeNWSE" Visibility="Collapsed" />
          </Grid>
        </Grid>
      </AdornerDecorator>
    </Grid>
    <ControlTemplate.Triggers>
      <Trigger Property="IsNonClientAreaActive" Value="False">
        <Setter Property="Background" TargetName="PART_SizeBorder"
                Value="{DynamicResource WindowInactiveOutterBackgroundBrush}" />
        <Setter Property="Background" TargetName="border3" Value="{DynamicResource WindowInactiveInnerBackgroundBrush}" />
      </Trigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="ResizeMode" Value="CanResizeWithGrip" />
          <Condition Property="WindowState" Value="Normal" />
        </MultiTrigger.Conditions>
        <Setter Property="Visibility" TargetName="PART_ResizeGrip" Value="Visible" />
      </MultiTrigger>
      <Trigger Property="WindowState" Value="Maximized">
        <Setter Property="Margin" TargetName="iconImage" Value="0,4,0,0" />
        <Setter Property="BorderThickness" TargetName="PART_SizeBorder" Value="0,0,0,0" />
        <Setter Property="CornerRadius" TargetName="PART_SizeBorder" Value="0,0,0,0" />
        <Setter Property="BorderThickness" TargetName="border2" Value="0,0,0,0" />
        <Setter Property="CornerRadius" TargetName="border2" Value="0,0,0,0" />
        <Setter Property="Margin" TargetName="PART_ButtonsPanel" Value="0,8,8,0" />
        <Setter Property="Visibility" TargetName="maximizeButton" Value="Collapsed" />
        <Setter Property="Margin" TargetName="adornerDecorator" Value="0" />
        <Setter Property="Margin" TargetName="contentPresenter" Value="8,6,8,8" />
        <Setter Property="Height" TargetName="border2" Value="54" />
      </Trigger>
      <Trigger Property="WindowState" Value="Normal">
        <Setter Property="Visibility" TargetName="normalizeButton" Value="Collapsed" />
      </Trigger>
      <Trigger Property="IsIconVisible" Value="False">
        <Setter Property="Visibility" TargetName="PART_IconImage" Value="Collapsed" />
      </Trigger>

    </ControlTemplate.Triggers>
  </ControlTemplate>
  <Style x:Key="CaptionButtonStyle" TargetType="{x:Type Button}">
    <Setter Property="Width" Value="35" />
    <Setter Property="Height" Value="19" />
    <Setter Property="Template" Value="{DynamicResource CaptionButtonControlTemplate}" />
  </Style>
  <ControlTemplate x:Key="CaptionButtonControlTemplate" TargetType="{x:Type Button}">
    <Grid Background="Transparent">
      <Border x:Name="hoverBorder" Margin="0" BorderBrush="{DynamicResource CaptionButtonHoverOutterBorderBrush}"
              BorderThickness="1" CornerRadius="2" Visibility="Collapsed">
        <Border x:Name="hoverBorderInner" BorderBrush="{DynamicResource CaptionButtonHoverInnerBorderBrush}"
                BorderThickness="1" CornerRadius="1" Background="{DynamicResource CaptionButtonHoverInnerBackgroundBrush}" />
      </Border>
      <Border x:Name="pressedBorder" Margin="0" BorderBrush="{DynamicResource CaptionButtonPressedOutterBorderBrush}"
              BorderThickness="1" CornerRadius="2" Visibility="Collapsed">
        <Border x:Name="pressedBorderInner" BorderBrush="{DynamicResource CaptionButtonPressedInnerBorderBrush}"
                BorderThickness="1" CornerRadius="1" Background="{DynamicResource CaptionButtonPressedInnerBackgroundBrush}" />
      </Border>
      <ContentPresenter Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center" />
    </Grid>
    <ControlTemplate.Triggers>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsMouseOver" Value="True" />
          <Condition Property="IsPressed" Value="False" />
        </MultiTrigger.Conditions>
        <Setter Property="Visibility" TargetName="hoverBorder" Value="Visible" />
      </MultiTrigger>
      <Trigger Property="IsPressed" Value="True">
        <Setter Property="Visibility" TargetName="pressedBorder" Value="Visible" />
      </Trigger>
      <Trigger Property="Background" Value="Red">
        <Setter Property="BorderBrush" TargetName="hoverBorder"
                Value="{DynamicResource CaptionButtonCloseHoverOutterBorderBrush}" />
        <Setter Property="BorderBrush" TargetName="hoverBorderInner"
                Value="{DynamicResource CaptionButtonCloseHoverInnerBorderBrush}" />
        <Setter Property="Background" TargetName="hoverBorderInner"
                Value="{DynamicResource CaptionButtonCloseHoverInnerBackgroundBrush}" />

        <Setter Property="BorderBrush" TargetName="pressedBorder"
                Value="{DynamicResource CaptionButtonClosePressedOutterBorderBrush}" />
        <Setter Property="BorderBrush" TargetName="pressedBorderInner"
                Value="{DynamicResource CaptionButtonClosePressedInnerBorderBrush}" />
        <Setter Property="Background" TargetName="pressedBorderInner"
                Value="{DynamicResource CaptionButtonClosePressedInnerBackgroundBrush}" />
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <Style x:Key="RibbonWindowStyle" TargetType="{x:Type Fluent:RibbonWindow}">
    <Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}" />
    <Setter Property="FontFamily" Value="{DynamicResource DefaultFontFamily}" />
    <Setter Property="FontWeight" Value="Normal" />
    <Setter Property="GlassBorderThickness" Value="8,50,8,8" />
    <Setter Property="ResizeBorderThickness" Value="8,8,8,8" />
    <Setter Property="CornerRadius" Value="15" />
    <Setter Property="CaptionHeight" Value="50" />
    <Setter Property="Foreground" Value="#FF000000" />
    <Setter Property="Template" Value="{StaticResource DwmRibbonWindowControlTemplate}" />
    <Setter Property="Background" Value="{DynamicResource WindowBackgroundBrush}" />
    <Setter Property="Fluent:FrameworkHelper.UseLayoutRounding" Value="True" />
    <Style.Triggers>
      <Trigger Property="IsCollapsed" Value="True">
        <Setter Property="GlassBorderThickness" Value="8,30,8,8" />
      </Trigger>
      <Trigger Property="WindowState" Value="Maximized">
        <Setter Property="GlassBorderThickness" Value="0,56,0,0" />
      </Trigger>
      <Trigger Property="IsDwmEnabled" Value="False">
        <Setter Property="Template" Value="{StaticResource NonDwmRibbonWindowControlTemplate}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style BasedOn="{StaticResource RibbonWindowStyle}" TargetType="{x:Type Fluent:RibbonWindow}" />
</ResourceDictionary>